package com.zhangdy.agent.resp;



public class AgentResponse {


    public static final int SUCCESS_CODE = 200;
    public static final int FAIL_CODE = 500;

    public static final AgentResponse SUCCESS = new AgentResponse(null);
    public static final AgentResponse FAIL = new AgentResponse(FAIL_CODE, "unknown exception");

    private int code;
    private String msg;
    private Object content;

    public AgentResponse(){}
    public AgentResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public AgentResponse(Object content) {
        this.code = SUCCESS_CODE;
        this.content = content;
    }

    public static AgentResponse fail(String message){
        AgentResponse agentResponse = new AgentResponse();
        agentResponse.setCode(FAIL_CODE);
        agentResponse.setMsg(message);
        return agentResponse;
    }

    public static AgentResponse ok(Object content){
        return new AgentResponse(content);
    }


    public static AgentResponse ok(){
        return SUCCESS;
    }

    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Object getContent() {
        return content;
    }
    public void setContent(AgentResponse content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
    }


}
